package com.hualan.sfzy.utils;

import org.bytedeco.javacv.FFmpegFrameGrabber;

public class VideoDurationExtractor {
    public static double getVideoDuration(String videoPath) {
        try (FFmpegFrameGrabber grabber = new FFmpegFrameGrabber(videoPath)) {
            grabber.start();
            double duration = grabber.getLengthInTime() / 1_000_000.0;
            grabber.stop();
            return duration;
        } catch (Exception e) {
            e.printStackTrace();
            return -1;
        }
    }


}
